﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using GameSchoolApplication.Models;
using GameSchoolApplication.Helper;


namespace GameSchoolApplication
{
	// Note: For instructions on enabling IIS6 or IIS7 classic mode, 
	// visit http://go.microsoft.com/?LinkId=9394801

	public class MvcApplication : System.Web.HttpApplication
	{
		public static void RegisterGlobalFilters(GlobalFilterCollection filters)
		{
			filters.Add(new HandleErrorAttribute());
		}

		public static void RegisterRoutes(RouteCollection routes)
		{
			routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

			routes.MapRoute(
				"Default", // Route name
				"{controller}/{action}/{id}", // URL with parameters
				new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
			);

		}

		protected void Application_Start()
		{

			Database.SetInitializer(new MyDbContextInitializer());

			AreaRegistration.RegisterAllAreas();

			RegisterGlobalFilters(GlobalFilters.Filters);
			RegisterRoutes(RouteTable.Routes);
		}


        public class MyDbContextInitializer : CreateDatabaseIfNotExists<GameSchoolWebContext>
		{
			protected override void Seed(GameSchoolWebContext context)
			{
				base.Seed(context);

                context.Persons.Add(new Person
                                        {
                                           Name = "Ingvar Sigurðsson",
                                           UserName = "gvarihendrix",
                                           RememberMe = false,
                                           Group = "Student",
                                           Email = "gvarihendrix@gmail.com",
                                           Password = "qwerty123",
                                           
                                         });

                context.Persons.Add(new Person
                                        {
                                          Name = "Ragnar Clausen",
                                          UserName = "LexLethal",
                                          RememberMe = false,
                                          Group = "Student",
                                          Email = "raggiclausen@gmail.com",
                                          Password = "qwerty123",

                                         });

                 context.Persons.Add(new Person
                                        {
                                          Name = "Inga Berþórsdóttir",
                                          UserName = "GoslingLover",
                                          RememberMe = false,
                                          Group = "Student",
                                          Email = "ingab11@ru.is",
                                          Password = "qwerty123",

                                        });

                 context.Persons.Add(new Person
                                       {
                                          Name = "Elísa Erludóttir",
                                          UserName = "BugsBunny",
                                          RememberMe = false,
                                          Group = "Student",
                                          Email = "elisae11@ru.is",
                                          Password = "qwerty123",

                                        });

                 context.Persons.Add(new Person
                                       {
                                          Name = "Konráð Guðmundsson",
                                          UserName = "Kony2012",
                                          RememberMe = false,
                                          Group = "Student",
                                          Email = "konrad11@ru.is",
                                          Password = "qwerty123",

                                        });

                  context.Persons.Add(new Person
                                       {
                                          Name = "Shane Vendrell",
                                          UserName = "CletusVanDamme",
                                          RememberMe = false,
                                          Group = "Student",
                                          Email = "cletus@aol.com",
                                          Password = "qwerty123",

                                        });

                  context.Persons.Add(new Person
                                      {
                                        Name = "Cosmo Kramer",
                                        UserName = "FreewayRicky",
                                        RememberMe = false,
                                        Group = "Student",
                                        Email = "cosmo@yahoo.com",
                                        Password = "qwerty123",

                                       });

                  context.Persons.Add(new Person
                                     {
                                       Name = "George Costanza",
                                       UserName = "ArtVandelay",
                                       RememberMe = false,
                                       Group = "Student",
                                       Email = "gcoz@yahoo.com",
                                       Password = "qwerty123",

                                      });

                  context.Persons.Add(new Person
                                      {
                                       Name = "Ellis Carver",
                                       UserName = "FuzzyDunlop",
                                       RememberMe = false,
                                       Group = "Student",
                                       Email = "carv@bcpd.com",
                                       Password = "qwerty123",

                                       });

                  context.Persons.Add(new Person
                                      {
                                       Name = "Harrison Ford",
                                       UserName = "HardbodyHarrison",
                                       RememberMe = false,
                                       Group = "Student",
                                       Email = "indiana@lucasarts.com",
                                       Password = "qwerty123",

                                      });

                  context.Persons.Add(new Person
                                      {
                                          Name = "Daníel Brandur Sigurgeirsson",
                                          UserName = "dabs",
                                          RememberMe = false,
                                          Group = "Teacher",
                                          Email = "dabs@ru.is",
                                          Password = "qwerty123",
                                      });

                  context.Persons.Add(new Person
                                      {
                                         Name = "John Keating",
                                         UserName = "mycaptain",
                                         RememberMe = false,
                                         Group = "Teacher",
                                         Email = "keats@ru.is",
                                         Password = "qwerty123",
                                       });

                  context.Persons.Add(new Person
                                      {
                                        Name = "Glenn Holland",
                                        UserName = "opus",
                                        RememberMe = false,
                                        Group = "Teacher",
                                        Email = "dreyfuss@ru.is",
                                        Password = "qwerty123",
                                       });

                  context.Persons.Add(new Person
                                     {
                                        Name = "Jón Jónsson",
                                        UserName = "johnnyboy",
                                        RememberMe = false,
                                        Group = "Student",
                                        Email = "JoeyJoeJoe@ru.is",
                                        Password = "asdf",
                                      });

                context.Persons.Add(new Person
                                    {
                                        Name = "admin",
                                        UserName = "admin", 
                                        RememberMe = false,
                                        Group = "Supervisor",
                                        Email = "admin@gameschool.is",
                                        Password = "admin",

                                    });


				context.Games.Add(new Game
								  {
									  Title = "Entertainment Extravaganza",
									  Description = "Testing your knowledge in the world of film and tv",
									  AuthorId = 14,
									  //ListOfLevels = LevelListi.GetLevelList(),
									  GameId = 1,

								  });

				context.Levels.Add(new Level
				{
					Title = "Gamaersaman",
					GameId = 1,
				});



			}
		}
	}
}